/*
 * Print.h
 *
 *  Created on: 26-10-2011
 *      Author: cristian
 */

#ifndef PRINT_H_
#define PRINT_H_

#include "Logger.h"
#include "WorkerSpace.h"

class Print {

private:
	Logger* logger;
public:
	Print();
	virtual ~Print();
	static void printMatConsola(WorkerSpace* ambiente, unsigned int x, unsigned int y);

};

inline void Print::printMatConsola(WorkerSpace* ambiente, unsigned int x, unsigned int y) {

	//TODO hacer nueva forma de iterar sobre el workspace
	for (unsigned int f = 0; f < x; f++) {
		for (unsigned int c = 0; c < y; c++) {

			if (typeid(ambiente->getNodo(f, c)) == typeid(WorkerSpace*) && ambiente->getNodo(f, c) != NULL) {

				WorkerSpace* wp = (WorkerSpace*) ambiente->getNodo(f, c);

				if (wp->isRun()) {
					printf("%s%s%i ", ANSI_RED, ANSI_BACKGROUND_WHITE, (wp->getId() ));
				} else {
					printf("%s%s%i ", ANSI_BLACK, ANSI_BACKGROUND_RED, (wp->getId()));
				}

				printf("%s", ANSI_RESET);
				fflush(stdout);
			} else {
				printf("%s%s ", ANSI_BLUE, "#");
				printf("%s", ANSI_RESET);
				fflush(stdout);
			}

		}

		printf("\n");
	}

}

Print::Print() {
	this->logger = new Logger();

}

Print::~Print() {
	delete this->logger;
}

#endif /* PRINT_H_ */
